home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks96
/
AhhhhhhHack.sit
/
Ahhhhhh Hack
/
AhhInit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-22
|
2KB
|
94 lines
/* #include files */
#include "A4Stuff.h"
#include "SetupA4.h"
#include "AhhGlobals.h"
/* #defines */
#define kINITid 0
#define SEGMENTED FALSE /* define if we have a multiple segment INIT */
#define kNumSegments 2 /* total number of segments, including INIT resource itself */
/* some globals local to this file */
/* SystemTask patch stuff */
typedef pascal void (*ReleaseResourceProc)(Handle releaseMe);
ReleaseResourceProc gOldReleaseResourceAddr;
pascal void ReleaseResourcePatch(Handle releaseMe);
/* main */
void main(void)
{
long oldA4;
Handle h;
#ifdef USE_DEBUGGER_CALLS
Debugger();
#endif
/* set up our A4 context for _this file_ */
oldA4 = SetCurrentA4();
RememberA4();
/* detach ourselves */
h = Get1Resource('INIT', kINITid);
if (h) DetachResource(h);
/* initialize the globals in _this file_ */
gOldReleaseResourceAddr = 0L;
/* initialize the globals in the _other file_ */
/* this also forces the code in the other segment to be loaded */
/* we must force all other segments to be loaded at this point */
/* so we can detach them below */
SetMeUp();
/* now that we are sure that all segments have been loaded */
/* (since we called at least one routine in each segment) */
/* we can continue by detaching each one */
#if SEGMENTED
{
short i;
for (i=kINITid+1;i<kNumSegments;++i) {
h = Get1Resource('INIc', i); /* should NOT fail since each segment should already be loaded and locked */
if (h) DetachResource(h);
}
}
#endif
/* patch SystemTask */
gOldReleaseResourceAddr = (ReleaseResourceProc)GetToolTrapAddress(_ReleaseResource);
SetToolTrapAddress((UniversalProcPtr)ReleaseResourcePatch, _ReleaseResource);
/* restore the a4 world */
SetA4(oldA4);
}
/* SystemTaskPatch */
pascal void ReleaseResourcePatch(Handle releaseMe)
{
long oldA4;
#ifdef USE_DEBUGGER_CALLS
Debugger();
#endif
/* use the global data in _this file_ */
oldA4 = SetUpA4();
/* test the globals in the _other file_ */
PlayMySound();
/* call through to the original SystemTask */
gOldReleaseResourceAddr(releaseMe);
/* restore the a4 world */
RestoreA4(oldA4);
}